#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "bmock_in_out_raw_mem.hpp"
#include "bmock_util.hpp"
#include "detail/bmock_raw_mem.hpp"
#include "detail/bmock_test_control_tools.hpp"
#include <cstring>

static const unsigned char   str1[]   = "qwertyuiop[]";
static const unsigned char   str2[]  = "asdfghjkl;'zxcvbnm,./";
static const unsigned char   expected[] = "\x0D\x00\x00\x00"
"\x16\x00\x00\x00"
"\x10\x00\x00\x00"
"\x33\x00\x00\x00"
"qwertyuiop[]\x00"
"asdfghjkl;'zxcvbnm,./";
static const size_t L1         = sizeof(str1);
static const size_t L2         = sizeof(str2);
static const size_t L3         = sizeof(expected);

namespace bmock {
	BOOST_AUTO_TEST_CASE(test_in_usigned_str2) {
		BOOST_CHECK_NO_THROW(
			in_out_raw_mem_descr<char>  io_str1 = in_out_str(str1,str2);

		BOOST_CHECK_EQUAL(L3,mismatch_at(expected,expected+L3,io_str1.get_ptr()));
		);
	}

	BOOST_AUTO_TEST_CASE(test_next_unsigned_str_OK) {
		const control_tools_ptr t(new test_control_tools());
		raw_mem_checker            chk(t);
		in_out_raw_mem_descr<char> io_str1 = in_out_str(str1,str2);
		const char        name[] = "str1";
		chk.set_location(location(__FILE__,__LINE__+2));
		BOOST_CHECK_NO_THROW(
			const in_out_rm_pair iop_str2(io_str1,name,chk);
		BOOST_CHECK_EQUAL(L1-1,strlen((const char *)iop_str2.first.begin()));
		BOOST_CHECK_EQUAL(L2-1,strlen((const char *)iop_str2.second.begin()));
		BOOST_CHECK_EQUAL(L2,mismatch_at(iop_str2.second.begin(),iop_str2.second.end(),str2));
		);
	}
}